Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit e8a303fd6faaef48dca0ae715c69b1c03ecbd662


Parents : fd94d8d
Author : Sudo-Ivan <ivan@quad4.io>
Signature : Signature validation error
Date : 2026-01-18T16:18:13-06:00

Add DOMPurify initialization in frontend test setup

- Integrated DOMPurify for sanitizing HTML in tests.
- Added error handling for DOMPurify initialization to ensure robustness.
- Made DOMPurify globally accessible in the test environment.

Changes

1 files changed, 19 insertions(+), 0 deletions(-)


Diff

diff --git a/tests/frontend/setup.js b/tests/frontend/setup.js
index 23426f4d..2258a9a6 100644
--- a/tests/frontend/setup.js
+++ b/tests/frontend/setup.js
@@ -1,7 +1,26 @@
import { vi } from "vitest";
import { config } from "@vue/test-utils";
+import createDOMPurify from "dompurify";
+
+// Initialize DOMPurify with the jsdom window
+let DOMPurify;
+try {
+ if (typeof createDOMPurify === "function") {
+ DOMPurify = createDOMPurify(window);
+ } else if (createDOMPurify && typeof createDOMPurify.default === "function") {
+ DOMPurify = createDOMPurify.default(window);
+ } else {
+ DOMPurify = createDOMPurify;
+ }
+} catch (e) {
+ console.error("Failed to initialize DOMPurify:", e);
+}
// Global mocks
+if (DOMPurify) {
+ global.DOMPurify = DOMPurify;
+ window.DOMPurify = DOMPurify;
+}
global.performance.mark = vi.fn();
global.performance.measure = vi.fn();
global.performance.getEntriesByName = vi.fn(() => []);


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────